import { defineStore } from "pinia";

interface StateInterface {
  token: string;
  menuList: Array<any>;
  headTab: string;
}

export const userStore = defineStore("user", {
  state: (): StateInterface => {
    return {
      token: "11",
      menuList: [], //菜单信息
      headTab: ''
    };
  },
  getters: {
    headerToken: (state: StateInterface) => `header ${state.token}`,
  },
  actions: {
    changeToken(token: string) {
      this.token = token;
    },
    //菜单
    setMenuList(data: Array<any>) {
      this.menuList = data;
    },
    setTab(data: string) {
      this.headTab = data;
    },
  },
  persist: true
});
